# FROM libretranslate/libretranslate:v1.4.0
FROM alpine:latest

# FROM alpine:3.17

WORKDIR /home/app

# 安装python3环境和gunicorn环境
RUN echo "https://mirrors.aliyun.com/alpine/edge/main/" > /etc/apk/repositories \
    && echo "https://mirrors.aliyun.com/alpine/edge/community/" >> /etc/apk/repositories \
    && apk update \
    && apk add --no-cache --update python3 py3-pip \
    && python3 -V && pip3 -V \
    && ln -sf /usr/bin/pip3 /usr/bin/pip \
    && mkdir -p ~/.pip \ 
    && echo "[global]" > ~/.pip/pip.conf \
    && echo "index-url=https://pypi.tuna.tsinghua.edu.cn/simple/" >> ~/.pip/pip.conf \
    && echo "[install]" >> ~/.pip/pip.conf \
    && echo "trusted-host=pypi.tuna.tsinghua.edu.cn" >> ~/.pip/pip.conf \
    && python -m venv /path/to/venv \
    && . /path/to/venv/bin/activate \ 
    && pip install --upgrade pip --break-system-packages \
    && pip install wheel --break-system-packages

COPY ./requirements.txt /home/app

RUN pip install -r requirements.txt --break-system-packages
# RUN pip install ctranslate2==3.20.0 \
#     && pip install libretranslate==1.4.0

COPY . /home/app

# CMD "gunicorn app:app -p app.pid -b 0.0.0.0:80 -w 2"
# CMD ["gunicorn", "app:app", "-p", "app.pid", "-b", "0.0.0.0:80"]
CMD ["libretranslate", "--load-only", "zh,en,ja", "--debug"]
